
package com.until.service;

	

	import java.sql.SQLException;
	import java.util.ArrayList;
import java.util.Date;

import com.until.entiy.denglu;
import com.until.entiy.xinxi;
import com.util.DBManager;
	import com.util.QueryDataResult;

	public class XinxiManager {
		public ArrayList<xinxi> chaxun(){
			ArrayList<xinxi> list = new ArrayList<xinxi>();
			String sql = "select * from qichexinxiinfo";
			QueryDataResult qdr =DBManager.executeQuery(sql);
			if (qdr.rs!=null){
				try {
					while (qdr.rs.next()){
						int id=qdr.rs.getInt("id");
						int leibie=qdr.rs.getInt("leibie");
						String jiage=qdr.rs.getString("jiage");
						String name=qdr.rs.getString("name");
						
						Date shijian=qdr.rs.getDate("shijian");
						xinxi b = new xinxi(id,leibie,name,shijian,jiage);
						list.add(b);
					}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
			return list;
		}


		public int add (String leibie,String name,String shijian,String jiage){
			String sql = String.format
					("insert into qichexinxiinfo(leibie,name,shijian,jiage) values(%s,'%s','%s','%s')", leibie,name,shijian,jiage);
			
			
			int i =DBManager.executeUpdate(sql);
			return i;
			
		}
		
		public int del(int id) {
			String sql ="delete from qichexinxiinfo where id = "+id; 
		
			int i =DBManager.executeUpdate(sql);
			return i;
		}
	}




